home *** CD-ROM | disk | FTP | other *** search
- /* -----------------------------------------------------------------------------
-
- COPYIGHT
-
- ©1995 Dietmar Eilert (e-mail: DIETMAR@TOMATE.TNG.OCHE.DE). All Rights
- Reserved. Code may not be reused/reproduced without written permission of
- the author.
-
- Dietmar Eilert
- Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
- E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
- Tel: +49-(0)241-81665
- +49-(0)2525-7776
- Fax: +49-(0)241-81665
-
- Example: scan handler looking for C strucures. Scan handlers are plain
- functions (LoadSeg'ed by GED): no standard C startup code, no library calls.
-
- DICE-C:
-
- dcc struct.c -// -l0 -md -mRR -o ram:struct
-
- ------------------------------------------------------------------------------
- */
-
- #include <exec/types.h>
-
- #define UPPER(a) ((a) & 95)
-
- ULONG
- ScanHandlerStruct(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
- {
- const char *version = "$VER: Struct 1.0 (" __COMMODORE_DATE__ ")";
-
- UBYTE *from = *text;
-
- if (len > 8) {
-
- if ((from[0] == 't') && (from[1] == 'y') && (from[2] == 'p') && (from[3] == 'e') && (from[4] == 'd') && (from[5] == 'e') && (from[6] == 'f') && (from[7] == ' ')) {
-
- // ignore typedef keyword
-
- len -= 8;
- from += 8;
- }
- }
-
- if (len > 7) {
-
- if ((from[0] == 's') && (from[1] == 't') && (from[2] == 'r') && (from[3] == 'u') && (from[4] == 'c') && (from[5] == 't') && (from[6] == ' ')) {
-
- // found struct keyword
-
- UBYTE *last;
-
- for (last = from + len - 1; len && (*last == 32); --len)
- --last;
-
- from += 7;
- len -= 7;
-
- if ((*last != ',') && (*last != '*')) {
-
- UWORD pos = len;
-
- // check if there is a ';' in this line
-
- while (pos--)
- if (from[pos] == ';')
- return(FALSE);
-
- if (*from != '{') {
-
- *text = from;
-
- for (len = 0; (from <= last) && (*from >= 48); ++len)
- ++from;
-
- return(len);
- }
- }
- }
- }
-
- return(FALSE);
- }
-
-